using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using BL;
using BO;

namespace AnimalFarm.Product_manage
{
    public partial class AddDairyProduct : Telerik.WinControls.UI.RadForm
    {
        private int farmerID;

        public int FarmerID
        {
            get { return farmerID; }
            set { farmerID = value; }
        }
        B_Farmer B_farmer = new B_Farmer();
        B_DairyProduct B_dairy = new B_DairyProduct();
        public AddDairyProduct()
        {
            InitializeComponent();
        }

        private void btnAddDairyproduct_Click(object sender, EventArgs e)
        {
            string productName = txtProductName.Text;
            string descriptioin = txtDescription.Text;

            //insert into the database
            DairyProduct_Info info = new DairyProduct_Info();
            info.DairyProductName = productName;
            info.Description = descriptioin;
            info.FarmID = FarmerID;

            bool isOk = B_dairy.CreateOneDairyProduct(info);
            if (isOk)
            {
                MessageBox.Show(this, "Dairy product added successful", "Dairyproduct adding", MessageBoxButtons.OK, MessageBoxIcon.Information);
                resetFields();
            }
        }

        private void resetFields()
        {
            txtDescription.Text = "";
            txtProductName.Text = "";
            txtProductName.Focus();
        }

        private void AddDairyProduct_Load(object sender, EventArgs e)
        {
           
        }
    }
}
